//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.kitten.chatglmsdk.model;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Iterator;
import java.util.List;

public class ChatCompletionResponse {
    private String data;
    private String meta;
    private String id;
    private Long created;
    private String model;
    private List<Choice> choices;
    private Usage usage;

    public void setChoices(List<Choice> choices) {
        this.choices = choices;
        Iterator var2 = choices.iterator();

        while(var2.hasNext()) {
            Choice choice = (Choice)var2.next();
            if (!"stop".equals(choice.finishReason)) {
                if (null == this.data) {
                    this.data = "";
                }

                this.data = this.data.concat(choice.getDelta().getContent());
            }
        }

    }

    public void setUsage(Usage usage) {
        this.usage = usage;
        if (null != usage) {
            this.meta = JSON.toJSONString(ChatCompletionResponse.Meta.builder().usage(usage).build());
        }

    }

    public ChatCompletionResponse() {
    }

    public String getData() {
        return this.data;
    }

    public String getMeta() {
        return this.meta;
    }

    public String getId() {
        return this.id;
    }

    public Long getCreated() {
        return this.created;
    }

    public String getModel() {
        return this.model;
    }

    public List<Choice> getChoices() {
        return this.choices;
    }

    public Usage getUsage() {
        return this.usage;
    }

    public void setData(String data) {
        this.data = data;
    }

    public void setMeta(String meta) {
        this.meta = meta;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setCreated(Long created) {
        this.created = created;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ChatCompletionResponse)) {
            return false;
        } else {
            ChatCompletionResponse other = (ChatCompletionResponse)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label95: {
                    Object this$created = this.getCreated();
                    Object other$created = other.getCreated();
                    if (this$created == null) {
                        if (other$created == null) {
                            break label95;
                        }
                    } else if (this$created.equals(other$created)) {
                        break label95;
                    }

                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                Object this$meta = this.getMeta();
                Object other$meta = other.getMeta();
                if (this$meta == null) {
                    if (other$meta != null) {
                        return false;
                    }
                } else if (!this$meta.equals(other$meta)) {
                    return false;
                }

                label74: {
                    Object this$id = this.getId();
                    Object other$id = other.getId();
                    if (this$id == null) {
                        if (other$id == null) {
                            break label74;
                        }
                    } else if (this$id.equals(other$id)) {
                        break label74;
                    }

                    return false;
                }

                label67: {
                    Object this$model = this.getModel();
                    Object other$model = other.getModel();
                    if (this$model == null) {
                        if (other$model == null) {
                            break label67;
                        }
                    } else if (this$model.equals(other$model)) {
                        break label67;
                    }

                    return false;
                }

                Object this$choices = this.getChoices();
                Object other$choices = other.getChoices();
                if (this$choices == null) {
                    if (other$choices != null) {
                        return false;
                    }
                } else if (!this$choices.equals(other$choices)) {
                    return false;
                }

                Object this$usage = this.getUsage();
                Object other$usage = other.getUsage();
                if (this$usage == null) {
                    if (other$usage != null) {
                        return false;
                    }
                } else if (!this$usage.equals(other$usage)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ChatCompletionResponse;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        Object $created = this.getCreated();
        result = result * 59 + ($created == null ? 43 : $created.hashCode());
        Object $data = this.getData();
        result = result * 59 + ($data == null ? 43 : $data.hashCode());
        Object $meta = this.getMeta();
        result = result * 59 + ($meta == null ? 43 : $meta.hashCode());
        Object $id = this.getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        Object $model = this.getModel();
        result = result * 59 + ($model == null ? 43 : $model.hashCode());
        Object $choices = this.getChoices();
        result = result * 59 + ($choices == null ? 43 : $choices.hashCode());
        Object $usage = this.getUsage();
        result = result * 59 + ($usage == null ? 43 : $usage.hashCode());
        return result;
    }

    public String toString() {
        return "ChatCompletionResponse(data=" + this.getData() + ", meta=" + this.getMeta() + ", id=" + this.getId() + ", created=" + this.getCreated() + ", model=" + this.getModel() + ", choices=" + this.getChoices() + ", usage=" + this.getUsage() + ")";
    }

    public static class Usage {
        private int completion_tokens;
        private int prompt_tokens;
        private int total_tokens;

        public Usage() {
        }

        public int getCompletion_tokens() {
            return this.completion_tokens;
        }

        public int getPrompt_tokens() {
            return this.prompt_tokens;
        }

        public int getTotal_tokens() {
            return this.total_tokens;
        }

        public void setCompletion_tokens(int completion_tokens) {
            this.completion_tokens = completion_tokens;
        }

        public void setPrompt_tokens(int prompt_tokens) {
            this.prompt_tokens = prompt_tokens;
        }

        public void setTotal_tokens(int total_tokens) {
            this.total_tokens = total_tokens;
        }

        public boolean equals(Object o) {
            if (o == this) {
                return true;
            } else if (!(o instanceof Usage)) {
                return false;
            } else {
                Usage other = (Usage)o;
                if (!other.canEqual(this)) {
                    return false;
                } else if (this.getCompletion_tokens() != other.getCompletion_tokens()) {
                    return false;
                } else if (this.getPrompt_tokens() != other.getPrompt_tokens()) {
                    return false;
                } else {
                    return this.getTotal_tokens() == other.getTotal_tokens();
                }
            }
        }

        protected boolean canEqual(Object other) {
            return other instanceof Usage;
        }

        public int hashCode() {
            boolean PRIME = true;
            int result = 1;
            result = result * 59 + this.getCompletion_tokens();
            result = result * 59 + this.getPrompt_tokens();
            result = result * 59 + this.getTotal_tokens();
            return result;
        }

        public String toString() {
            return "ChatCompletionResponse.Usage(completion_tokens=" + this.getCompletion_tokens() + ", prompt_tokens=" + this.getPrompt_tokens() + ", total_tokens=" + this.getTotal_tokens() + ")";
        }
    }

    public static class Meta {
        private String task_status;
        private Usage usage;
        private String task_id;
        private String request_id;

        public static MetaBuilder builder() {
            return new MetaBuilder();
        }

        public String getTask_status() {
            return this.task_status;
        }

        public Usage getUsage() {
            return this.usage;
        }

        public String getTask_id() {
            return this.task_id;
        }

        public String getRequest_id() {
            return this.request_id;
        }

        public void setTask_status(String task_status) {
            this.task_status = task_status;
        }

        public void setUsage(Usage usage) {
            this.usage = usage;
        }

        public void setTask_id(String task_id) {
            this.task_id = task_id;
        }

        public void setRequest_id(String request_id) {
            this.request_id = request_id;
        }

        public boolean equals(Object o) {
            if (o == this) {
                return true;
            } else if (!(o instanceof Meta)) {
                return false;
            } else {
                Meta other = (Meta)o;
                if (!other.canEqual(this)) {
                    return false;
                } else {
                    label59: {
                        Object this$task_status = this.getTask_status();
                        Object other$task_status = other.getTask_status();
                        if (this$task_status == null) {
                            if (other$task_status == null) {
                                break label59;
                            }
                        } else if (this$task_status.equals(other$task_status)) {
                            break label59;
                        }

                        return false;
                    }

                    Object this$usage = this.getUsage();
                    Object other$usage = other.getUsage();
                    if (this$usage == null) {
                        if (other$usage != null) {
                            return false;
                        }
                    } else if (!this$usage.equals(other$usage)) {
                        return false;
                    }

                    Object this$task_id = this.getTask_id();
                    Object other$task_id = other.getTask_id();
                    if (this$task_id == null) {
                        if (other$task_id != null) {
                            return false;
                        }
                    } else if (!this$task_id.equals(other$task_id)) {
                        return false;
                    }

                    Object this$request_id = this.getRequest_id();
                    Object other$request_id = other.getRequest_id();
                    if (this$request_id == null) {
                        if (other$request_id != null) {
                            return false;
                        }
                    } else if (!this$request_id.equals(other$request_id)) {
                        return false;
                    }

                    return true;
                }
            }
        }

        protected boolean canEqual(Object other) {
            return other instanceof Meta;
        }

        public int hashCode() {
            boolean PRIME = true;
            int result = 1;
            Object $task_status = this.getTask_status();
            result = result * 59 + ($task_status == null ? 43 : $task_status.hashCode());
            Object $usage = this.getUsage();
            result = result * 59 + ($usage == null ? 43 : $usage.hashCode());
            Object $task_id = this.getTask_id();
            result = result * 59 + ($task_id == null ? 43 : $task_id.hashCode());
            Object $request_id = this.getRequest_id();
            result = result * 59 + ($request_id == null ? 43 : $request_id.hashCode());
            return result;
        }

        public String toString() {
            return "ChatCompletionResponse.Meta(task_status=" + this.getTask_status() + ", usage=" + this.getUsage() + ", task_id=" + this.getTask_id() + ", request_id=" + this.getRequest_id() + ")";
        }

        public Meta() {
        }

        public Meta(String task_status, Usage usage, String task_id, String request_id) {
            this.task_status = task_status;
            this.usage = usage;
            this.task_id = task_id;
            this.request_id = request_id;
        }

        public static class MetaBuilder {
            private String task_status;
            private Usage usage;
            private String task_id;
            private String request_id;

            MetaBuilder() {
            }

            public MetaBuilder task_status(String task_status) {
                this.task_status = task_status;
                return this;
            }

            public MetaBuilder usage(Usage usage) {
                this.usage = usage;
                return this;
            }

            public MetaBuilder task_id(String task_id) {
                this.task_id = task_id;
                return this;
            }

            public MetaBuilder request_id(String request_id) {
                this.request_id = request_id;
                return this;
            }

            public Meta build() {
                return new Meta(this.task_status, this.usage, this.task_id, this.request_id);
            }

            public String toString() {
                return "ChatCompletionResponse.Meta.MetaBuilder(task_status=" + this.task_status + ", usage=" + this.usage + ", task_id=" + this.task_id + ", request_id=" + this.request_id + ")";
            }
        }
    }

    public static class Delta {
        private String role;
        private String content;

        public Delta() {
        }

        public String getRole() {
            return this.role;
        }

        public String getContent() {
            return this.content;
        }

        public void setRole(String role) {
            this.role = role;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public boolean equals(Object o) {
            if (o == this) {
                return true;
            } else if (!(o instanceof Delta)) {
                return false;
            } else {
                Delta other = (Delta)o;
                if (!other.canEqual(this)) {
                    return false;
                } else {
                    Object this$role = this.getRole();
                    Object other$role = other.getRole();
                    if (this$role == null) {
                        if (other$role != null) {
                            return false;
                        }
                    } else if (!this$role.equals(other$role)) {
                        return false;
                    }

                    Object this$content = this.getContent();
                    Object other$content = other.getContent();
                    if (this$content == null) {
                        if (other$content != null) {
                            return false;
                        }
                    } else if (!this$content.equals(other$content)) {
                        return false;
                    }

                    return true;
                }
            }
        }

        protected boolean canEqual(Object other) {
            return other instanceof Delta;
        }

        public int hashCode() {
            boolean PRIME = true;
            int result = 1;
            Object $role = this.getRole();
            result = result * 59 + ($role == null ? 43 : $role.hashCode());
            Object $content = this.getContent();
            result = result * 59 + ($content == null ? 43 : $content.hashCode());
            return result;
        }

        public String toString() {
            return "ChatCompletionResponse.Delta(role=" + this.getRole() + ", content=" + this.getContent() + ")";
        }
    }

    public static class Choice {
        private Long index;
        @JsonProperty("finish_reason")
        private String finishReason;
        private Delta delta;

        public Choice() {
        }

        public Long getIndex() {
            return this.index;
        }

        public String getFinishReason() {
            return this.finishReason;
        }

        public Delta getDelta() {
            return this.delta;
        }

        public void setIndex(Long index) {
            this.index = index;
        }

        @JsonProperty("finish_reason")
        public void setFinishReason(String finishReason) {
            this.finishReason = finishReason;
        }

        public void setDelta(Delta delta) {
            this.delta = delta;
        }

        public boolean equals(Object o) {
            if (o == this) {
                return true;
            } else if (!(o instanceof Choice)) {
                return false;
            } else {
                Choice other = (Choice)o;
                if (!other.canEqual(this)) {
                    return false;
                } else {
                    label47: {
                        Object this$index = this.getIndex();
                        Object other$index = other.getIndex();
                        if (this$index == null) {
                            if (other$index == null) {
                                break label47;
                            }
                        } else if (this$index.equals(other$index)) {
                            break label47;
                        }

                        return false;
                    }

                    Object this$finishReason = this.getFinishReason();
                    Object other$finishReason = other.getFinishReason();
                    if (this$finishReason == null) {
                        if (other$finishReason != null) {
                            return false;
                        }
                    } else if (!this$finishReason.equals(other$finishReason)) {
                        return false;
                    }

                    Object this$delta = this.getDelta();
                    Object other$delta = other.getDelta();
                    if (this$delta == null) {
                        if (other$delta != null) {
                            return false;
                        }
                    } else if (!this$delta.equals(other$delta)) {
                        return false;
                    }

                    return true;
                }
            }
        }

        protected boolean canEqual(Object other) {
            return other instanceof Choice;
        }

        public int hashCode() {
            boolean PRIME = true;
            int result = 1;
            Object $index = this.getIndex();
            result = result * 59 + ($index == null ? 43 : $index.hashCode());
            Object $finishReason = this.getFinishReason();
            result = result * 59 + ($finishReason == null ? 43 : $finishReason.hashCode());
            Object $delta = this.getDelta();
            result = result * 59 + ($delta == null ? 43 : $delta.hashCode());
            return result;
        }

        public String toString() {
            return "ChatCompletionResponse.Choice(index=" + this.getIndex() + ", finishReason=" + this.getFinishReason() + ", delta=" + this.getDelta() + ")";
        }
    }
}
